/**
 * 多选框的全选事件
 */
// allCheck为全选的多选框的对象, checkname为多选框组的名字
function selectAll(allCheck, checkName) {
	if (allCheck.checked == true) {
		setAllCheck(true, checkName);
	} else {
		setAllCheck(false, checkName);
	}
}

// checkO被勾选的多选框, allCheck为全选的多选框的ID
function checkSelect(checkO, allCheck) {
	if (checkO.checked == true) {
		if (isSelectAll(checkO.name)) {
			document.getElementById(allCheck).checked = true;
		} else {
			document.getElementById(allCheck).checked = false;
		}
	} else {
		document.getElementById(allCheck).checked = false;
	}
}

function setAllCheck(checked, checkName) {
	var checks = document.getElementsByName(checkName);
	if (checks && checks.length > 0) {
		for ( var c = 0; c < checks.length; c++) {
			checks[c].checked = checked;
		}
	}
}

function isSelectAll(checkName) {
	var isAll = true;
	var checks = document.getElementsByName(checkName);
	if (checks && checks.length > 0) {
		for ( var c = 0; c < checks.length; c++) {
			if (checks[c].checked == false) {
				isAll = false;
				break;
			}
		}
	}
	return isAll;
}